# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=ruby-net-imap
_gemname=net-imap
# Keep version in sync with "Bundled gems" (https://stdgems.org) for the
# packaged Ruby version.
pkgver=0.4.10
pkgrel=0
pkgdesc="Ruby client api for Internet Message Access Protocol"
url="https://github.com/ruby/net-imap"
arch="noarch"
license="BSD-2-Clause AND Ruby"
depends="ruby"
makedepends="ruby-rdoc"
checkdepends="
	ruby-rake
	ruby-test-unit
	ruby-test-unit-ruby-core
	"
subpackages="$pkgname-doc"
source="https://github.com/ruby/net-imap/archive/v$pkgver/$_gemname-$pkgver.tar.gz
	gemspec.patch
	"
builddir="$srcdir/$_gemname-$pkgver"

prepare() {
	default_prepare
	sed -i '/require .bundler/d' Rakefile
}

build() {
	gem build $_gemname.gemspec
}

check() {
	rake test
}

package() {
	local gemdir="$pkgdir/$(ruby -e 'puts Gem.default_dir')"

	gem install \
		--local \
		--install-dir "$gemdir" \
		--ignore-dependencies \
		--document ri \
		--verbose \
		$_gemname

	# Remove unnessecary files
	cd "$gemdir"
	rm -rf build_info cache extensions plugins
}

doc() {
	pkgdesc="$pkgdesc (ri docs)"

	amove "$(ruby -e 'puts Gem.default_dir')"/doc
}

sha512sums="
0f05588dc80cef7f121cbb40e2e9ddd6cd44e5ba96ca8451ea32339275d394f1233bc6a8bc30aa1de6852f49a469e0ee64a3821d08e12199e4af51fca4e79ccf  net-imap-0.4.10.tar.gz
5ea3ff02e7faffc61400df54a7ebfbd7d2c034e135c0211355a0603b587405271a978db8876aaf4f2f06c0247fb55b1ad02b2ec85e536ce3df4480e9e89b69f9  gemspec.patch
"
